# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  filter_parameter_logging :password, :password_confirmation
  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '88402f9f39d00c2eed44e9e45204b5bc'

 

  def get_changes_saved_text(object)
    object.updated_at.strftime("Changes saved (%H:%M:%S)")
  end


  def flash_errors(object)
    object.errors.each_full do |e|
      flash[:error] = e
    end
  end
  

  def default_save_procedure(active_record)
    active_record.save

    if active_record.errors.empty?
      get_changes_saved_text(active_record)
      redirect_to :action => 'edit', :id => active_record.id
    else
      flash_errors(active_record)
      redirect_to :back
    end
  end
  
end
